]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
js: Remove unnecessary versions of clutter_actor_get_children
authorJasper St. Pierre <jstpierre@mecheye.net>
Wed, 30 May 2012 00:36:45 +0000 (20:36 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 11 Jun 2012 17:10:25 +0000 (13:10 -0400)
clutter_actor_get_children requires making a temporary GSList from
a linked list structure, and then creating a JS Array from that GSList.
For simple cases like the number of children, use clutter_actor_get_n_children.

https://bugzilla.gnome.org/show_bug.cgi?id=677426

js/ui/calendar.js
js/ui/endSessionDialog.js
js/ui/iconGrid.js
js/ui/lookingGlass.js
js/ui/messageTray.js
js/ui/overview.js
js/ui/popupMenu.js
js/ui/search.js
js/ui/shellMountOperation.js
js/ui/telepathyClient.js

index 9a7258a2dc6872c9261c7f9469dfba2ef01954da..c29828b887d3f22e23fd2d0afb079e2fa9fbd188 100644 (file)
@@ -448,7 +448,7 @@ const Calendar = new Lang.Class({
         }
 
         // All the children after this are days, and get removed when we update the calendar
-        this._firstDayIndex = this.actor.get_children().length;
+        this._firstDayIndex = this.actor.get_n_children();
     },
 
     _onStyleChange: function(actor, event) {
index cd6faa17eb3d0b3564f05a50949fee80a1a9901e..170df51f7a8470909c0c23dcf76c1eaa44699173 100644 (file)
@@ -31,7 +31,6 @@ const St = imports.gi.St;
 const Shell = imports.gi.Shell;
 
 const GnomeSession = imports.misc.gnomeSession;
-const Lightbox = imports.ui.lightbox;
 const Main = imports.ui.main;
 const ModalDialog = imports.ui.modalDialog;
 const Tweener = imports.ui.tweener;
@@ -288,13 +287,13 @@ const EndSessionDialog = new Lang.Class({
 
         this._applicationList.connect('actor-added',
                                       Lang.bind(this, function() {
-                                          if (this._applicationList.get_children().length == 1)
+                                          if (this._applicationList.get_n_children() == 1)
                                               scrollView.show();
                                       }));
 
         this._applicationList.connect('actor-removed',
                                       Lang.bind(this, function() {
-                                          if (this._applicationList.get_children().length == 0)
+                                          if (this._applicationList.get_n_children() == 0)
                                               scrollView.hide();
                                       }));
 
index 79293286866d4e1bb55a5ec0ba43860096363ad0..82a9552b80b5bd491eb2082f956299578e6b34a1 100644 (file)
@@ -309,10 +309,8 @@ const IconGrid = new Lang.Class({
         this._grid.queue_relayout();
     },
 
-    removeAll: function () {
-        this._grid.get_children().forEach(Lang.bind(this, function (child) {
-            child.destroy();
-        }));
+    removeAll: function() {
+        this._grid.destroy_all_children();
     },
 
     addItem: function(actor) {
@@ -320,10 +318,10 @@ const IconGrid = new Lang.Class({
     },
 
     getItemAtIndex: function(index) {
-        return this._grid.get_children()[index];
+        return this._grid.get_child_at_index(index);
     },
 
     visibleItemsCount: function() {
-        return this._grid.get_children().length - this._grid.get_n_skip_paint();
+        return this._grid.get_n_children() - this._grid.get_n_skip_paint();
     }
 });
index 0adf312c375152dc3258d16c4e1b09b62f19584e..962f81516e34d977041169abf7a90b29c78bdb87 100644 (file)
@@ -38,7 +38,7 @@ var commandHeader = 'const Clutter = imports.gi.Clutter; ' +
                     'const stage = global.stage; ' +
                     'const color = function(pixel) { let c= new Clutter.Color(); c.from_pixel(pixel); return c; }; ' +
                     /* Special lookingGlass functions */
-                       'const it = Main.lookingGlass.getIt(); ' +
+                    'const it = Main.lookingGlass.getIt(); ' +
                     'const r = Lang.bind(Main.lookingGlass, Main.lookingGlass.getResult); ';
 
 const HISTORY_KEY = 'looking-glass-history';
@@ -320,7 +320,7 @@ const WindowList = new Lang.Class({
     },
 
     _updateWindowList: function() {
-        this.actor.get_children().forEach(function (actor) { actor.destroy(); });
+        this.actor.destroy_all_children();
         let windows = global.get_window_actors();
         let tracker = Shell.WindowTracker.get_default();
         for (let i = 0; i < windows.length; i++) {
@@ -378,7 +378,7 @@ const ObjInspector = new Lang.Class({
             this._previousObj = null;
         this._obj = obj;
 
-        this._container.get_children().forEach(function (child) { child.destroy(); });
+        this._container.destroy_all_children();
 
         let hbox = new St.BoxLayout({ style_class: 'lg-obj-inspector-title' });
         this._container.add_actor(hbox);
index d29684f2679be7587e5dbccbb0698c049a50c5ca..1e110ca6cb1c398a0871d43abf3afad8c94ee545 100644 (file)
@@ -756,7 +756,7 @@ const Notification = new Lang.Class({
             button.label = label;
         }
 
-        if (this._buttonBox.get_children().length > 0)
+        if (this._buttonBox.get_n_children() > 0)
             this._buttonFocusManager.remove_group(this._buttonBox);
 
         this._buttonBox.add(button);
@@ -1284,7 +1284,7 @@ const SummaryItem = new Lang.Class({
     },
 
     prepareNotificationStackForShowing: function() {
-        if (this.notificationStack.get_children().length > 0)
+        if (this.notificationStack.get_n_children() > 0)
             return;
 
         for (let i = 0; i < this.source.notifications.length; i++) {
@@ -1293,7 +1293,6 @@ const SummaryItem = new Lang.Class({
     },
 
     doneShowingNotificationStack: function() {
-        let notificationActors = this.notificationStack.get_children();
         for (let i = 0; i < this._stackedNotifications.length; i++) {
             let stackedNotification = this._stackedNotifications[i];
             let notification = stackedNotification.notification;
@@ -1323,7 +1322,7 @@ const SummaryItem = new Lang.Class({
         this._stackedNotifications.push(stackedNotification);
         if (!this.source.isChat)
             notification.enableScrolling(false);
-        if (this.notificationStack.get_children().length > 0)
+        if (this.notificationStack.get_n_children() > 0)
             notification.setIconVisible(false);
         this.notificationStack.add(notification.actor);
         notification.expand(false);
@@ -2436,7 +2435,7 @@ const MessageTray = new Lang.Class({
     },
 
     _onSummaryBoxPointerContentUpdated: function() {
-        if (this._summaryBoxPointerItem.notificationStack.get_children().length == 0)
+        if (this._summaryBoxPointerItem.notificationStack.get_n_children() == 0)
             this._hideSummaryBoxPointer();
         this._adjustSummaryBoxPointerPosition();
 
@@ -2470,7 +2469,7 @@ const MessageTray = new Lang.Class({
         // We should be sure to hide the box pointer if all notifications in it are destroyed while
         // it is hiding, so that we don't show an an animation of an empty blob being hidden.
         if (this._summaryBoxPointerState == State.HIDING &&
-            this._summaryBoxPointerItem.notificationStack.get_children().length == 0) {
+            this._summaryBoxPointerItem.notificationStack.get_n_children() == 0) {
             this._summaryBoxPointer.actor.hide();
             return;
         }
index 59dc71c42908ea4e089918b5e244ba7690a627bc..2690f08a46f7cdd752dee11ff2f87df96bb94e66 100644 (file)
@@ -14,7 +14,6 @@ const AppDisplay = imports.ui.appDisplay;
 const ContactDisplay = imports.ui.contactDisplay;
 const Dash = imports.ui.dash;
 const DND = imports.ui.dnd;
-const Lightbox = imports.ui.lightbox;
 const Main = imports.ui.main;
 const MessageTray = imports.ui.messageTray;
 const Panel = imports.ui.panel;
index 9efb6f74da0fd4f96537efc28eaa20c8500246f5..873e3395b8723b838dc8a41169706a06aba2cd64 100644 (file)
@@ -906,7 +906,7 @@ const PopupMenuBase = new Lang.Class({
     },
 
     isEmpty: function() {
-        return this.box.get_children().length == 0;
+        return this.box.get_n_children() == 0;
     },
 
     isChildMenu: function(menu) {
index 86255fa1f962eea2067ce3168b953fb4a041e1ff..df5e192aba437fdd7de77609707d496b9d6e2e1d 100644 (file)
@@ -51,7 +51,7 @@ const SearchResultDisplay = new Lang.Class({
      * Remove all results from this display.
      */
     clear: function() {
-        this.actor.get_children().forEach(function (actor) { actor.destroy(); });
+        this.actor.destroy_all_children();
     },
 
     /**
index 6a44a247d429abdd046b5bc9b89155d8c0e4ddb0..f9f3bb89936f24dde7de93b6837a1dff487114d8 100644 (file)
@@ -347,13 +347,13 @@ const ShellProcessesDialog = new Lang.Class({
 
         this._applicationList.connect('actor-added',
                                       Lang.bind(this, function() {
-                                          if (this._applicationList.get_children().length == 1)
+                                          if (this._applicationList.get_n_children() == 1)
                                               scrollView.show();
                                       }));
 
         this._applicationList.connect('actor-removed',
                                       Lang.bind(this, function() {
-                                          if (this._applicationList.get_children().length == 0)
+                                          if (this._applicationList.get_n_children() == 0)
                                               scrollView.hide();
                                       }));
     },
index 91568495a7e46d7654736f7f17f7bd9cca5a5395..aecf64370e2de89caad85a8694f0dc2365f1fea8 100644 (file)
@@ -802,7 +802,7 @@ const ChatNotification = new Lang.Class({
         let groups = this._contentArea.get_children();
         for (let i = 0; i < groups.length; i++) {
             let group = groups[i];
-            if (group.get_children().length == 0)
+            if (group.get_n_children() == 0)
                 group.destroy();
         }
     },